import time

from selenium.webdriver.common.by import By

from page.base import Base
from page.login import Login
from page.register import Register


class Main(Base):
    _base_url = "http://demo.pan.rubinchu.com/"
    def goto_register(self):
        time.sleep(3)
        register_btn = self.driver.find_element(By.XPATH,'//*[@class="m--up"]')
        self.driver.execute_script("arguments[0].click();",register_btn)
        return Register(self.driver)
    #登录
    def goto_login(self):
        ele_usrname = '//*[@class="form sign-in"]/label[1]/input'
        ele_password ='//*[@class="form sign-in"]/label[2]/input'
        login_btn = '//*[@class="el-button submit el-button--warning is-round"]'
        num = time.strftime('%H%M%s',time.localtime(time.time()))
        self.driver.find_element(By.XPATH,ele_usrname).send_keys("usr"+num)
        time.sleep(3)
        self.driver.find_element(By.XPATH, ele_password).send_keys('pass'+num)
        time.sleep(2)
        self.driver.find_element(By.XPATH,login_btn).click()
        return Login(self.driver)